<?php

namespace app\wap\controller;

class Book extends Base
{
    /**
     * index #
     *
     * @auth kouweihong
     * @date 2020/12/2
     * @throws \think\db\exception\DbException
     */
    public function index()
    {
        $pageSize = 15;
        $page = input('page', 1);

        $where = ['status' => \app\common\model\Book::STATUS_0];
        $list = \app\common\model\Book::where($where)->order('id desc')->paginate($pageSize);

        $this->success($list);
    }

    /**
     * read #书籍详情
     * api post /{controller}/{method}
     * @param int id 书籍ID
     *
     * @param $id
     * @auth kouweihong
     * @date 2020/12/4
     */
    public function read($id)
    {
        //获取参数
        $id || $id = input('id');
        $id || $this->error('参数错误');

        //查询
        $info = \app\common\model\Book::scope('status')->find($id);
        $info || $this->error('信息记录不存在');

        $this->success($info);
    }
}
